package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	IOTypeEventNew           = "wms.IOTypeNew"
	IOTypeEventBeforeCreate  = "wms.IOTypeBeforeCreate"
	IOTypeEventBeforeUpdate  = "wms.IOTypeBeforeUpdate"
	IOTypeEventBeforeSave    = "wms.IOTypeBeforeCreate wms.IOTypeBeforeUpdate"
	IOTypeEventAfterCreate   = "wms.IOTypeAfterCreate"
	IOTypeEventAfterUpdate   = "wms.IOTypeAfterUpdate"
	IOTypeEventAfterSave     = "wms.IOTypeAfterCreate wms.IOTypeAfterUpdate"
	IOTypeEventDelete        = "wms.IOTypeDelete"
	IOTypeAccessControlEvent = "wms.IOTypeAccessControl"
)

func GetIOTypeConfig() *mgo.DocConfig {
	return IOType_Config
}

var IOType_Config *mgo.DocConfig

func init() {
	IOType_Config = NewIOTypeConfig()
}
func NewIOTypeConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "wms.IOType",
		Fields: []string{
			"name", "flag", "isAdd", "sort", "l", "r", "level", "link", "parent", "children", "color", "background", "group", "step", "warn",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetIOTypeConfig,
				DocName:    "IOType",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetIOTypeConfig,
				DocName:    "IOType",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
